package com.enqualcomm.kids.mvp.chat;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.enqualcomm.kids.R;

/**
 * Created by yinzhiqun on 2015/6/24.
 */
public class ChatDialog extends Dialog implements View.OnClickListener {
    private String playMode;
    private CallBack callBack;
    private boolean isdelete = false;

    public ChatDialog(Context context, String playMode, CallBack callBack) {
        super(context);
        this.playMode = playMode;
        this.callBack = callBack;
    }

    public ChatDialog(Context context, boolean isdelete, CallBack callBack) {
        super(context);
        this.isdelete = isdelete;
        this.callBack = callBack;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_chat);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        initView();
    }

    private void initView() {
        TextView tv1 = (TextView) findViewById(R.id.tv1);
        tv1.setText(playMode);
        tv1.setOnClickListener(this);
        if (isdelete) {
            tv1.setVisibility(View.GONE);
        }
        findViewById(R.id.tv2).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.tv1) {
            callBack.onClick1();
        } else {
            callBack.onClick2();
        }
        dismiss();
    }

    public interface CallBack {
        void onClick1();

        void onClick2();
    }
}
